package cn.z2huo.knowledge.collection.set.repeat;

import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;

/**
 * <p>通过 HashSet 和 LinkedHashSet 对 List 进行去重
 *
 * @author z2huo
 */
public class ListNoRepeatBySet {

    public static void main(String[] args) {

        HashSet<String> stringHashSet = new HashSet<>(initList());
        System.out.println(stringHashSet);

        LinkedHashSet<String> stringLinkedHashSet = new LinkedHashSet<>(initList());
        System.out.println(stringLinkedHashSet);
    }

    public static List<String> initList() {
        List<String> list =  List.of("999", "aaa", "bbb", "121212", "aaaa", "aaa", "999");
        return list;
    }

}
